package com.web.forum.web;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.web.forum.ao.InvitationAo;

@Controller
@RequestMapping("/invitation")
public class InvitationAction
{
	@Autowired
	private InvitationAo invitationAo;
	
	@RequestMapping("/post")
	public ModelAndView post(HttpServletRequest request,HttpServletResponse response,String title,String content,long forumId)
	{
		invitationAo.post (request ,title ,content ,forumId);
		
		try
		{
			response.sendRedirect ("/forum/success.shtml?forumId="+forumId);
		}catch (IOException e)
		{
			e.printStackTrace();
		}
		
		return null;
	}
	
	@RequestMapping("/reply")
	public ModelAndView reply(HttpServletRequest request,HttpServletResponse response,long forumId,long workId,long commentId,long comment_MId,String content)
	{
		invitationAo.reply (request ,forumId ,workId ,commentId ,comment_MId ,content);
		try
		{
			response.sendRedirect ("/forum/re_success.shtml?comment_MId="+comment_MId+"&forumId="+forumId+"&workId="+workId);
		}catch (IOException e)
		{
			e.printStackTrace();
		}
		
		return null;
	}
	
	
	
}
